All Questions
13 questions
1vote
1answer
48views
Search and replace content
PIN A 1 1:3 0:8 0 0:0 PIN B 1 1:0 0 0:0 Z Z:0 PIN C 1 1:3 0:8 0 0:0 Z Z:0 I would like to change the content on PIN A & PIN C only without affecting PIN B to 0 0:3 Z 0:3 Can't seem to find a ...
-1votes
1answer
332views
I want to replace a specific word in a text file and save the results in multiple text files using perl or ubuntu command?
I have a file results.txt that contains the following: the word: word1 is a not detected And I have a txt file contain the list of words as following: word1 word2 word3 ... And I want to generate ...
1vote
2answers
888views
Perl pattern match and substitute to replace only 4th word and retain everything else
I need to replace the 4th word on every line with 0: Original: R5_427 MMP15@2:S VDD:1 967.796 TC1=0.0004785156 R5_428 MMP15@2:S lninst_M55:S 0.001 Expected output: R5_427 MMP15@2:S VDD:1 0 TC1=0....
0votes
2answers
493views
How to do find and replace strings on file after it is being modified
Trying to achieve following: 1) New file gets uploaded with the same file name but with new content 2) Event triggers that checks the file for specific strings and replaces them 3) The file can be ...
1vote
2answers
5kviews
Replace multi line string with multi line string without escaping by hand
Say I have a text file text.txt and I want to replace a (multi-line) string that is contained in before.txt with another string that is contained in after.txt, how do I do that? (I dont want to use ...
0votes
2answers
917views
Why is my multi-line perl string replace adding a blank line?
I'm trying to replace multiple lines in a text file (an XML element with an unknown number of children) with the contents of a separate text file. I've managed to get the replace mostly working using ...
3votes
1answer
160views
How to prevent from destroying symlinks, using Perl when to replace with sed regex?
Based on How do I prevent sed -i from destroying symlinks?, but I use Perl. I tried by middle of all these questions: Is there a way to make perl -i not clobber symlinks? perl symlink on gz file How ...
0votes
1answer
75views
How do I extract a portion of an SQL statement for the purposes of searching and replacing?
I'm using bash shell attempting to do a search and replace. I have a file of lines that look like ... INSERT INTO currency (name, code, symbol) VALUES ('Baht', 'THB', '฿'); ... and I want to convert ...
1vote
2answers
659views
Search and replace is not respecting my "$1" token
Using bash shell on Ubuntu 14.04. Trying to do a simple search and replace on every line of a file. I have tried perl -pi -e "s/.*/DELETE FROM my_object_times where ID = '$1';/g" ids.csv but this ...
1vote
2answers
93views
SED Search and Replace on Linux [duplicate]
I want to change the value from 1521 to 1525 in FROM_HOST only in file gexhosts.cat: FROM_HOST db201521 TO_HOST db201521 Is there a way to do that or some work around? I would really prefer if ...
2votes
2answers
2kviews
Replacing matching text after two matching lines
I have a YAML file which includes a stanza looks this: admin::common::passwords: alice: password: '$6$oTQhLvN/4VFJPscD$8LYwUMSFi' bob: password: '$6$JKOtLF0wHeZfIskt$W/M5.ugDS' If the ...
9votes
2answers
15kviews
Remove unknown unicode character from textfiles - sed, other bash/shell methods
I need to search and replace all occurences of an unknown character in some files having the same name. Opening such files with vi, I read <91> code for that character. Opening them with nano, I ...
3votes
5answers
1kviews
Replacing lines in files with file contents
I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like foo <?php include("file1.php"); ?> bar baz <?php include("file2....